import React, {useState,useEffect} from 'react'

export default function HookCounterChangeTitle() {
    const [counter, setCounter] = useState(0);
    //useEffect的第一个参数是一个回调函数，当组件重新渲染的时候就会执行这个回调函数
    useEffect(() => {
        document.title = counter;
       
    })
    return (
        <div>
            <h2>当前计数： {counter}</h2>
            <button onClick={e => setCounter(counter+1)}>+1</button>
        </div>
    )
}
